home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sun4c.md / timerTick.h < prev    next >
C/C++ Source or Header  |  1990-09-06  |  3KB  |  115 lines

  1. /*
  2.  * timerTick.h --
  3.  *
  4.  *      Declarations for the Sun3 machine dependent clock timer.
  5.  *
  6.  * Copyright 1985, 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * rcsid: $Header: /sprite/src/kernel/timer/sun4c.md/RCS/timerTick.h,v 1.2 90/09/06 18:22:15 jhh Exp $ SPRITE (Berkeley) 
  16.  */
  17.  
  18. #ifndef _TIMERTICK
  19. #define _TIMERTICK
  20.  
  21. #include "spriteTime.h"
  22.  
  23. /* DATA STRUCTURES: */
  24.  
  25.  
  26. /*
  27.  * On the Sun-3, Timer_Ticks is just a Time value because the free-running
  28.  * counter keeps track of time.
  29.  */
  30. typedef Time Timer_Ticks;
  31.  
  32.  
  33. /*
  34.  * Definitions for useful intervals and clock values. 
  35.  * See timer.h for more details.
  36.  */
  37.  
  38.  extern unsigned int     timer_IntZeroSeconds; 
  39.  extern unsigned int     timer_IntOneMillisecond;   
  40.  extern unsigned int     timer_IntOneSecond;
  41.  extern unsigned int     timer_IntOneMinute;
  42.  extern unsigned int     timer_IntOneHour; 
  43.  extern Timer_Ticks    timer_TicksZeroSeconds;
  44.  extern Time         timer_MaxIntervalTime; 
  45.  
  46.  
  47.  
  48. /*
  49.  * Because the Sun3's timer speaks in the same units as type Time, we can
  50.  * use the Time_ modules routines to Add and Subtract
  51.  */
  52.  
  53. #ifdef lint
  54. #define Timer_AddTicks(a,b,c)      Time_Add((* ((Time *) &a)),\
  55.                         (* ((Time *) &b)), \
  56.                         (Time *) c)
  57. #define Timer_SubtractTicks(a,b,c) Time_Subtract((* ((Time *) &a)), \
  58.                          (* ((Time *) &b)), \
  59.                          (Time *) c)
  60. #else /* lint */
  61. #define Timer_AddTicks(a,b,c)      Time_Add(a,b,c)
  62. #define Timer_SubtractTicks(a,b,c) Time_Subtract(a,b,c)
  63. #endif /* lint */
  64.  
  65. /*
  66.  * Conversion to Ticks to Time and Time to Ticks is fast too.
  67.  */
  68.  
  69. #define Timer_TicksToTime(a,b)        *(b) = a;
  70. #define Timer_TimeToTicks(a,b)        *(b) = a;
  71.  
  72.  
  73. extern void Timer_AddIntervalToTicks _ARGS_((Timer_Ticks absolute, 
  74.             unsigned int interval, Timer_Ticks *resultPtr));
  75. extern void Timer_GetCurrentTicks _ARGS_((Timer_Ticks *ticksPtr));
  76.  
  77.  
  78. /*
  79.  *----------------------------------------------------------------------
  80.  *
  81.  * Tick Comparisons --
  82.  *
  83.  *    Timer_TickLT:    tick1  <   tick2
  84.  *    Timer_TickLE:    tick1  <=  tick2
  85.  *    Timer_TickEQ:    tick1  ==  tick2
  86.  *    Timer_TickGE:    tick1  >=  tick2
  87.  *    Timer_TickGT:    tick1  >   tick2
  88.  *
  89.  * Results:
  90.  *     TRUE    - the relation holds for the 2 values.
  91.  *     FALSE    - the relation does not hold.
  92.  *
  93.  * Side effects:
  94.  *     None.
  95.  *
  96.  *----------------------------------------------------------------------
  97.  */
  98.  
  99. #ifdef lint
  100. #define Timer_TickLT(a,b)    Time_LT((* ((Time *) &a)), (* ((Time *) &b)))
  101. #define Timer_TickLE(a,b)    Time_LE((* ((Time *) &a)), (* ((Time *) &b)))
  102. #define Timer_TickEQ(a,b)    Time_EQ((* ((Time *) &a)), (* ((Time *) &b)))
  103. #define Timer_TickGE(a,b)    Time_GE((* ((Time *) &a)), (* ((Time *) &b)))
  104. #define Timer_TickGT(a,b)    Time_GT((* ((Time *) &a)), (* ((Time *) &b)))
  105. #else /* lint */
  106. #define Timer_TickLT(a,b)    Time_LT(a,b)
  107. #define Timer_TickLE(a,b)    Time_LE(a,b)
  108. #define Timer_TickEQ(a,b)    Time_EQ(a,b)
  109. #define Timer_TickGE(a,b)    Time_GE(a,b)
  110. #define Timer_TickGT(a,b)    Time_GT(a,b)
  111. #endif /* lint */
  112.  
  113. #endif /* _TIMERTICK */
  114.  
  115.